<template>
  <a-layout style="height: 1200px">
    <a-layout-header class="header">
      <div class="logo" />
      <div style="float: right; color: white">
        您好： {{ member.mobile }} &nbsp;&nbsp;
        <router-link to="/login">退出登录</router-link>
      </div>
      <a-menu
        v-model:selectedKeys="selectedKeys"
        theme="dark"
        mode="horizontal"
        :style="{ lineHeight: '64px' }"
      >
        <a-menu-item key="/welcome">
          <router-link to="/welcome">
            <CoffeeOutlined /> &nbsp; 欢迎页面
          </router-link>
        </a-menu-item>
        <a-menu-item key="/passenger">
          <router-link to="/passenger">
            <UserOutlined /> &nbsp; 乘车人管理
          </router-link>
        </a-menu-item>
        <a-menu-item key="3">nav 3</a-menu-item>
      </a-menu>
    </a-layout-header>
    <a-layout>
      <a-layout-sider width="200" style="background: #fff">
        <a-menu
          v-model:selectedKeys="selectedKeys"
          v-model:openKeys="openKeys"
          mode="inline"
          :style="{ height: '100%', borderRight: 0 }"
        >
          <a-sub-menu key="sub1">
            <template #title>
              <span>
                <user-outlined />
                会员管理
              </span>
            </template>
            <a-menu-item key="/welcome">
              <router-link to="/welcome">
                <CoffeeOutlined /> &nbsp; 欢迎页面
              </router-link>
            </a-menu-item>
            <a-menu-item key="/passenger">
              <router-link to="/passenger">
                <UserOutlined /> &nbsp; 乘车人管理
              </router-link>
            </a-menu-item>
            <a-menu-item key="3">option3</a-menu-item>
          </a-sub-menu>
        </a-menu>
      </a-layout-sider>
      <a-layout style="padding: 0 24px 24px">
        <a-breadcrumb style="margin: 16px 0">
          <a-breadcrumb-item>Home</a-breadcrumb-item>
          <a-breadcrumb-item>List</a-breadcrumb-item>
          <a-breadcrumb-item>App</a-breadcrumb-item>
        </a-breadcrumb>
        <a-layout-content
          :style="{
            background: '#fff',
            padding: '24px',
            margin: 0,
            minHeight: '280px',
          }"
        >
          <router-view></router-view>
        </a-layout-content>
      </a-layout>
    </a-layout>
  </a-layout>
</template>
<script setup>
import store from "@/store";
import { ref, watch } from "vue";
const selectedKeys = ref(["1"]);
const openKeys = ref(["sub1"]);
import router from "@/router";

watch(
  () => router.currentRoute.value.path,
  // 当路由有变化的时候，执行这个函数. newValue是最新的路由
  (newValue) => {
    console.log("watch", newValue);
    // selectedKeys.value = [];
    // 把新路由值放到  selectedKeys
    // selectedKeys.value.push(newValue);
  },
  { immediate: true }
);

const member = store.state.member;
</script>
<style scoped>
.logo {
  float: left;
  width: 120px;
  height: 31px;
  margin: 16px 24px 16px 0;
  background: rgba(255, 255, 255, 0.3);
}

.ant-row-rtl .logo {
  float: right;
  margin: 16px 0 16px 24px;
}

.site-layout-background {
  background: #fff;
}
</style>
@/store
